<?php

Raise::load('core.RaiseException');

/**
 * TestException class
 * Testing unit of 'phpraise/exception/*Exception.php'
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestException extends RaiseTest{

    public static function testExistence(){
        self::assertClassExists('RaiseException');
        self::assertClassExists('RaiseInvalidArgumentException');
        self::assertClassExists('RaiseInvalidRequestException');
        self::assertClassExists('RaiseFileNotFoundException');
        self::assertClassExists('RaiseFileOperationFailedException');
        self::assertClassExists('RaiseNotImplementedException');
        self::assertClassExists('RaiseRemoteConnectionException');
        self::assertClassExists('RaiseNetworkOperationFailedException');
        self::assertClassExists('RaiseNullArgumentException');
        self::assertClassExists('RaiseClientIdExistException');
        self::assertClassExists('RaiseStaticClassConstructionException');
        self::assertClassExists('RaiseDOMParseException');
        self::assertClassExists('RaiseIncompatiblePluginException');
        self::assertClassExists('RaiseUserAccessDeniedException');
        self::assertClassExists('RaisePageNotFoundException');
        self::assertClassExists('RaiseNoConnectionMadeException');

        $s = 'Testing Exception Message';

        $exception = new RaiseInvalidArgumentException($s);
        self::assertClassExtends('RaiseInvalidArgumentException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseInvalidArgumentException');
        self::assertStrictEqual($exception->getCode(), 10001);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseInvalidRequestException($s);
        self::assertClassExtends('RaiseInvalidRequestException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseInvalidRequestException');
        self::assertStrictEqual($exception->getCode(), 10002);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseFileNotFoundException($s);
        self::assertClassExtends('RaiseFileNotFoundException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseFileNotFoundException');
        self::assertStrictEqual($exception->getCode(), 10003);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseFileOperationFailedException($s);
        self::assertClassExtends('RaiseFileOperationFailedException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseFileOperationFailedException');
        self::assertStrictEqual($exception->getCode(), 10004);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseNotImplementedException($s);
        self::assertClassExtends('RaiseNotImplementedException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseNotImplementedException');
        self::assertStrictEqual($exception->getCode(), 10005);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseRemoteConnectionException($s);
        self::assertClassExtends('RaiseRemoteConnectionException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseRemoteConnectionException');
        self::assertStrictEqual($exception->getCode(), 10006);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseNetworkOperationFailedException($s);
        self::assertClassExtends('RaiseNetworkOperationFailedException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseNetworkOperationFailedException');
        self::assertStrictEqual($exception->getCode(), 10007);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseNullArgumentException($s);
        self::assertClassExtends('RaiseNullArgumentException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseNullArgumentException');
        self::assertStrictEqual($exception->getCode(), 10008);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseClientIdExistException($s);
        self::assertClassExtends('RaiseClientIdExistException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseClientIdExistException');
        self::assertStrictEqual($exception->getCode(), 10009);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseStaticClassConstructionException($s);
        self::assertClassExtends('RaiseStaticClassConstructionException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseStaticClassConstructionException');
        self::assertStrictEqual($exception->getCode(), 10010);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseDOMParseException($s);
        self::assertClassExtends('RaiseDOMParseException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseDOMParseException');
        self::assertStrictEqual($exception->getCode(), 10011);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseIncompatiblePluginException($s);
        self::assertClassExtends('RaiseIncompatiblePluginException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseIncompatiblePluginException');
        self::assertStrictEqual($exception->getCode(), 10012);
        self::assertStrictEqual($exception->getMessage(), $s);
        
        $exception = new RaiseUserAccessDeniedException($s);
        self::assertClassExtends('RaiseUserAccessDeniedException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseUserAccessDeniedException');
        self::assertStrictEqual($exception->getCode(), 10014);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaisePageNotFoundException($s);
        self::assertClassExtends('RaisePageNotFoundException', 'RaiseException');
        self::assertObjectClass($exception, 'RaisePageNotFoundException');
        self::assertStrictEqual($exception->getCode(), 10015);
        self::assertStrictEqual($exception->getMessage(), $s);

        $exception = new RaiseNoConnectionMadeException($s);
        self::assertClassExtends('RaiseNoConnectionMadeException', 'RaiseException');
        self::assertObjectClass($exception, 'RaiseNoConnectionMadeException');
        self::assertStrictEqual($exception->getCode(), 10016);
        self::assertStrictEqual($exception->getMessage(), $s);
    }
    
}
